package com.chen.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chen.pojo.Article;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author chenchao

 */
@Mapper
public interface ArticleMapper extends BaseMapper<Article> {

    //查询最新的五条数据
    @Select(" select * from article order by id desc limit 0,5 ")
    List<Article> articleLis();

    @Select("select *from article where author=#{author}")
    List<Article> list(String author);

    //    查询分类的列表
    @Select("select * from article where author=#{author} and category=#{category}")
    List<Article> categorys(@Param("author") String author,@Param("category") String category);

    //统计分类的数量
    @Select("select count(*) count,category ,id from article  where author=#{author} group by category")
    List<Article> categoryList(String author);


    @Update("update article set counts=#{counts} where id=#{id}")
    int likerCounts( Article article);


    @Select("select *from article where id=#{id}")
    Article selectArticleOne(@Param("id") int id);

    @Select("select *from article where flag=1")
    List<Article> selectArticleByFlag();

//    浏览量
    @Select("select sum(counts) as seeCount from article")
    int seeCount();

//    查询举报文章

    @Select("select id,author,title,utime from article where isEnable=0")
    List<Article> isEnable();


    @Select("select count(*) as articleCounts from article")
    int articleCount();



}
